package cn.itlaobing.eshopmanagement.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;

import cn.itlaobing.eshopmanagement.entity.Member;
import cn.itlaobing.eshopmanagement.mapper.MemberMapper;
import cn.itlaobing.eshopmanagement.service.MemberService;
@Service
public class MemberServiceImpl implements MemberService {
	
	@Autowired
	private MemberMapper memberMapper;

	    //列表显示所有的会员
		@Override
		public List<Member> findBySearchFilter(Map<String, String> searchFilter) {
			if(searchFilter==null){
				searchFilter=new HashMap<>();
			}else{
				if(StringUtils.isBlank(searchFilter.get("pageNum"))){
					searchFilter.put("pageNum","1");
					
				}
				if(StringUtils.isBlank(searchFilter.get("pageSize"))){
					searchFilter.put("pageSize","3");
				}
			}		
			PageHelper.startPage(searchFilter); //map中需要包含 pageNum 和pageSize 
			return memberMapper.findBySearchFilter(searchFilter);
        }
		//根据id查看会员详情
		@Override
		public Member selectById(long id) {
			
			return memberMapper.selectByPrimaryKey(id);
		}
		
		
		
		
}